<template>
  <div class="spec-preview">
    <vue-photo-zoom-pro
      :high-url="newImg || img"
      :out-zoomer="true"
      type="circle"
    >
      <img :src="newImg || img"/>
    </vue-photo-zoom-pro>
    
    
  </div>
</template>

<script>
import vuePhotoZoomPro from 'vue-photo-zoom-pro'
import 'vue-photo-zoom-pro/dist/style/vue-photo-zoom-pro.css'
  export default {
    name: "Zoom",
    data(){
      return{
        newImg:""
      }
    },
    props:["img"],
    components:{
      vuePhotoZoomPro,
    },
    mounted(){
      //自定义全局中央事件
      this.$bus.$on("getImgUrl",(value)=>{
        //更新img 数据
        this.newImg = value;
      })
    },
    beforeDestroy(){
      this.$bus.$off("getImgUrl");
    }
  }
</script>

<style lang="less">
  .spec-preview {
    position: relative;
    width: 400px;
    height: 400px;
    border: 1px solid #ccc;

    img {
      width: 100%;
      height: 100%;
    }

    .zoomer{
      z-index: 100;
      height: 400px !important;
      width: 400px !important;
      top: 0 !important;
    }

    .selector {
      background: rgba(228, 116, 41,0.3);
    }

    
  }
</style>